<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  测试
  git reset HEAD~
  第二次测试
  git reset HEAD~
  第三次测试
  git reflog



  sdfsdfsd
  <script>
      const nodes = [{
        name: '1.0', id: 1, children: [
          { name: '1.0.1' },
          { name: '1.0.2' },
          { name: '1.0.3', children: [
            { name: '1.0.3.1' }
          ] 
        }
        ] 
      }]

      function isArrayLike( obj ) {
          let length = !!obj && "length" in obj && obj.length;
          if(typeof obj == 'function' || (obj != null && obj === obj.window)){
              return false;
          }
          return Array.isArray(obj) || length === 0 ||
              typeof length === "number" && length > 0 && ( length - 1 ) in obj;
      }

      function arrayEach(list, iterate, context) {
          for (let index = 0, len = list.length; index < len; index++) {
              const flag = iterate.call(context, list[index], index, list);
              if(flag === false) {
                  break;
              }
          }
      }

      function objEach(target, iterate, context) {
          for (let key in target) {
              if (target.hasOwnProperty(key)) {
                  const flag = iterate.call(context, target[key], key, target);
                  if(flag === false) {
                      break;
                  }
              }
          }
      }

      function each(target, iterate, context) {
          if(target) {
              isArrayLike(target) ? arrayEach(target, iterate, context) : objEach(target, iterate, context);
          }
      }

      function getParentNode(nodes, curNode, parentNode) {
          each(nodes, (node) => {
              if(curNode != node) {
                  if(node.children && node.children.length > 0) {
                      parentNode = getParentNode(node.children, curNode, node)
                  }
              }else{
                  return false
              }
          })
          return parentNode;
      }

      console.log(getParentNode(nodes, nodes[0].children[2].children[0]))
  </script>
</body>

</html>